var model = require('../models/proModel'),
  errCode = require('../../conf/errorCode'),
  wrap = require('../helper/wrap'),
  conf = require('../../conf/const'),
  util = require('../helper/util'),
  _ = require('lodash');

exports.addPro = function(data, callback) {
  if (!data.pro || !data.leader || !data.member || !data.description) {
    return callback({errNo: errCode.LESS_OF_DATA_ERROR});
  }
  model.addPro(
    wrap.changeData(data, wrap.names.pro, wrap.names.front, wrap.names.end),
    (err, result) => {
      if (err) return callback(err);
      return callback(null, result);
    },
  );
};

exports.getProByProId = function(data, callback) {
  if (!data.proId) {
    return callback({errNo: errCode.LESS_OF_DATA_ERROR});
  }
  model.getProById(data.proId, callback);
};

exports.getOnlineProByProName = function(data, callback) {
  if (!data.pro) {
    return callback({errNo: errCode.LESS_OF_DATA_ERROR});
  }
  model.getOnlineProByProName(data, callback);
};
